<?php

/**
 * Groups Housing template
 *
 */
	if(bp_get_group_status()=='public')
	{
		 $embedcity=str_replace("-","+",bp_get_current_group_slug());
		 $embedstate=trim(strip_tags(bp_get_group_description()));
	}
	else
	{
		$groupid=bp_get_group_id();
		$group=$wpdb->get_results($wpdb->prepare("
			SELECT city,state
			FROM wp_twyne_group_code_assgn
			WHERE group_id=%d",$groupid));
		$embedcity=str_replace(' ','+',trim($group[0]->city));
		$embedstate=trim($group[0]->state);
	}
		$geocode_url = 'http://maps.googleapis.com/maps/api/geocode/json?address='.$embedcity.',+'.$embedstate.'&sensor=false';
		 $ch = curl_init( $geocode_url );
		 $options = array(
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_HTTPHEADER => array('Content-type: application/json')
		);
		
		curl_setopt_array( $ch, $options );
		$result =  curl_exec($ch);
		//echo $result;
		curl_close($ch);
		$temp=json_decode($result,true);
		$lat=$temp["results"][0]["geometry"]["location"]["lat"];
		$lng=$temp["results"][0]["geometry"]["location"]["lng"];
 ?>
<div id="padmapper-embed">
	<iframe width="700" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.padmapper.com/?lat=<?php echo $lat?>&lng=<?php echo $lng?>&minRent=0&maxRent=6000&searchTerms=Words+Required+In+Listing&maxPricePerBedroom=6000&minBR=0&maxBR=10&minBA=1&maxAge=7&imagesOnly=false&phoneReq=false&cats=false&dogs=false&noFee=false&showSubs=true&showNonSubs=true&showRooms=true&userId=-1&cl=true&apts=true&rnt=true&ood=true&zoom=4&favsOnly=false&onlyHQ=true&showHidden=false&workplaceLat=0&workplaceLong=0&maxTime=0&ver=1"></iframe><br /><small><a href="https://www.padmapper.com/?lat=<?php echo $lat?>&lng=<?php echo $lng?>&minRent=0&maxRent=6000&searchTerms=Words+Required+In+Listing&maxPricePerBedroom=6000&minBR=0&maxBR=10&minBA=1&maxAge=7&imagesOnly=false&phoneReq=false&cats=false&dogs=false&noFee=false&showSubs=true&showNonSubs=true&showRooms=true&userId=-1&cl=true&apts=true&rnt=true&ood=true&zoom=4&favsOnly=false&onlyHQ=true&showHidden=false&workplaceLat=0&workplaceLong=0&maxTime=0" style="color:#0000FF;text-align:left">View Larger Map</a>, Powered by PadMapper <a href="https://www.padmapper.com" style="color:#0000FF;text-align:left">Apartment Search</a></small>
</div>